import tkinter as tk
import math

window=tk.Tk()
window.title("物理随机性实验")
window.geometry("380x250")


t1=tk.Text(window,height=2,width=50,bg="pink")
t1.insert("end","please insert the length under me")
t1.pack()

e1=tk.Entry(window,width=50,bg="pink")
e1.pack()

t3=tk.Text(window,height=2,width=50,bg="pink")
t3.insert("end","please insert the position under me")
t3.pack()

e2=tk.Entry(window,width=50,bg="pink")
e2.pack()



t2=tk.Text(window,height=2,width=50,bg="pink")
t2.pack()




global n
global m
global flag
n=0
m=0
def text_get():
    n=e1.get()
    m=str(e2.get())
    #print(m)
    g=9.801
    t=math.sqrt((2*float(n))/g)
    #print(t)
    #print(t/0.32)
    w=(t/(0.31))%1

    print(w)
    if w<0.25 or w>0.75:
        if m=="正":
            t2.insert("end","正")
        else:
            t2.insert("end","反")
    else:
        if m=="正":

            t2.insert("end","反")
        else:
            t2.insert("end","正")

def text_clean():
    t2.delete(0.0,"end")


b1=tk.Button(window,height=2,width=50,text="点击查看理论方向",bg="pink",command=text_get)
b1.pack()
b2=tk.Button(window,height=2,width=50,text="点击清空",bg="pink",command=text_clean)
b2.pack()
#c1=tk.Canvas(window,height=200,width=380,bg="pink")
#c1.pack()

window.mainloop()

